package com.zhiyin.seal.constant;

import java.util.Arrays;
import java.util.Optional;

/**
 * 支付状态
 */
public enum PaymentStatusEnum implements BaseEnum {
    WAIT_PAY(0, "待支付"),

    SUCESS(1, "交易成功"),

    FAIL(2, "交易失败");

    private Integer value;
    private String desc;

    PaymentStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return value;
    }
    @Override
    public String getDesc() {
        return desc;
    }

    public static PaymentStatusEnum valueOf(Integer status) {
        PaymentStatusEnum[] values = PaymentStatusEnum.values();
        Optional<PaymentStatusEnum> first = Arrays.stream(values).filter(e -> e.getValue().equals(status)).findFirst();
        return !first.isPresent() ? null : first.get();
    }

    public static boolean isExist(Integer status) {
        PaymentStatusEnum judgeEnum = valueOf(status);
        return judgeEnum != null;
    }
}
